
/**
 * AppleIIGo
 * TimeMaster II H.O. class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "TimeMasterIIHO.h"

TimeMasterIIHO::TimeMasterIIHO(Motherboard * motherboard,
							   char * slotDeviceName) :
SlotDevice(motherboard, slotDeviceName) {
}

void TimeMasterIIHO::onMemoryRequested() {
	romMemoryOffset =
	motherboard->getMemory()->requestMemory(TIMEMASTERIIHO_ROM_BYTENUM);
}

void TimeMasterIIHO::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "AE TimeMaster II H.O. ROM Rev. 5.bin";
	motherboard->getResources()->readResource(romMemory, 
											  TIMEMASTERIIHO_ROM_BYTENUM,
											  romImage);
}

void TimeMasterIIHO::writeIo(UINT16 address, UINT8 value) {
}

UINT8 TimeMasterIIHO::readIo(UINT16 address) {
	return timingGenerator->readFloatingBus();
}

UINT8 TimeMasterIIHO::readMemory(UINT16 address) {
	if ((address & 0xff8) == 0xff8)
		return timingGenerator->readFloatingBus();
	else if (address & 0x800)
		return romMemory[(address & 0x7ff) | 0x800];
	else
		return romMemory[(address & 0xff) | 0x800];
}
